package com.lishe.lishe.lishe.module.excitation.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.lishe.lishe.Imageloader.ImageLoaderUtils;
import com.lishe.lishe.R;
import com.lishe.lishe.lishe.MyRecyclerView.RecyclerviewBaseAdapter;
import com.lishe.lishe.lishe.module.excitation.bean.user.UserObject;
import com.nostra13.universalimageloader.core.DisplayImageOptions;

import java.util.List;

/**
 * Created by shino on 2017/10/31.
 * 点赞对象适配器
 */

public class SelectedPersonAdapter extends RecyclerviewBaseAdapter {
    private List<UserObject> users;
    private ImageLoaderUtils imageLoaderUtils;
    private DisplayImageOptions option;

    public SelectedPersonAdapter(List<UserObject> users) {
        this.users = users;
        imageLoaderUtils = new ImageLoaderUtils();
        option = imageLoaderUtils.setOptionsImage(R.mipmap.head);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolderMy(ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_dianzan_person, null);
        DianZanPersonHolder holder = new DianZanPersonHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolderMy(RecyclerView.ViewHolder holder0, int position) {
        DianZanPersonHolder holder = (DianZanPersonHolder) holder0;
        UserObject user = users.get(position);
        holder.name.setText(user.getEmpName());
        imageLoaderUtils.displayImage(user.getAvatarPath(), holder.headImg,option);
    }

    @Override
    public int getItemCountMy() {
        return users == null ? 0 : users.size();
    }

    @Override
    public int getItemViewTypeMy(int position) {
        return 0;
    }

    class DianZanPersonHolder extends RecyclerView.ViewHolder {

        TextView name;
        ImageView headImg;

        public DianZanPersonHolder(View itemView) {
            super(itemView);
            name = itemView.findViewById(R.id.name);
            headImg = itemView.findViewById(R.id.headImg);
        }
    }
}
